#include <iterator>
#include <cassert>

template <class Iterator>
class IteratorRange {
public:
	typedef Iterator const_iterator;
	typedef std::reverse_iterator<Iterator> reverse_const_iterator;

	IteratorRange<Iterator>() {}
	const_iterator begin() const { return begin_; }
	reverse_const_iterator rbegin() const
	{
		return std::reverse_iterator<Iterator>(end_);
	}
	const_iterator end() const { return end_; }
	reverse_const_iterator rend() const
	{
		return std::reverse_iterator<Iterator>(begin_); 
	}
	IteratorRange<Iterator>(const Iterator left, const Iterator right)
	{
		begin_ = left, end_ = right;
	}
	size_t size() const { return end_ - begin_; }
	IteratorRange<const_iterator> Shrink(const int dl, const int dr) const
	{
		assert(dl + dr <= end_ - begin_); return IteratorRange<const_iterator>(begin_ + dl, end_ - dr);
	}
	IteratorRange<reverse_const_iterator> Reversed() const
	{
		return IteratorRange<reverse_const_iterator>(rbegin(), rend());
	}
private:
	Iterator begin_, end_;
};